package com.hlf.modules.merchant.store.controller;

import com.hlf.common.annotation.SysLog;
import com.hlf.common.utils.PageUtils;
import com.hlf.common.utils.ReturnResult;
import com.hlf.modules.merchant.store.entity.Store;
import com.hlf.modules.merchant.store.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 门店列表
 */
@RestController
@RequestMapping("store/")
public class StoreController {
    @Autowired
    private StoreService storeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//	@RequiresPermissions("store:view")
    public ReturnResult list(@RequestParam Map<String, Object> params) {
        PageUtils pageUtil = storeService.queryListForPage(params);
        return ReturnResult.ok().put("page", pageUtil);
    }

    /**
     * 通过id查找门店信息
     */
    @RequestMapping("/info/{storeId}")
    public ReturnResult config(@PathVariable("storeId") String storeId) {
        Store store = storeService.queryObject(Long.parseLong(storeId));
        return ReturnResult.ok().put("store", store);
    }


    /**
     * 新增门店
     */
    @SysLog("新增门店")
    @RequestMapping("/saveStore")
    public ReturnResult save(Store store) {
        storeService.save(store);
        return ReturnResult.ok();
    }

    /**
     *修改门店
     */
    @RequestMapping("/updateStore")
    public ReturnResult update(Store store) {
        storeService.update(store);
        return ReturnResult.ok();
    }

    /**
     * 删除门店
     */
    @SysLog("删除门店")
    @RequestMapping("/delete")
    public ReturnResult delete(@RequestBody Long[] storeIds) {

        storeService.deleteBatch(storeIds);
        return ReturnResult.ok();
    }




}
